import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:wechat_manager/components/side_menu_view.dart';
import 'package:wechat_manager/pages/content/publish/publish_view.dart';
import 'package:wechat_manager/pages/dashboard/dashboard_view.dart';
import 'package:wechat_manager/pages/user/User.dart';
import '../pages/content/draft/draft_view.dart';
import '../pages/home/home_view.dart';
import '../pages/material/material_view.dart';

final GlobalKey<NavigatorState> parentNavigatorKey = GlobalKey<NavigatorState>();
final GlobalKey<NavigatorState> childNavigatorKey = GlobalKey<NavigatorState>();


final GoRouter routers = GoRouter(
  navigatorKey: parentNavigatorKey,
  initialLocation: '/',
  routes: <RouteBase>[
    GoRoute(
      path: '/',
      builder: (BuildContext context, GoRouterState state) {
        return HomePage(title: "Demo");
      },
    ),
  ],
);

final GoRouter childRouters = GoRouter(
  navigatorKey: childNavigatorKey,
  initialLocation: '/dashboard',
  routes: <RouteBase>[
    ShellRoute(
      builder: (BuildContext context, GoRouterState state, Widget child) {
        return Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            const SideMenuView(),
            const VerticalDivider(
              width: 0,
            ),
            Expanded(
                child: child
            ),
          ],
        );
      },

      routes: [
        GoRoute(
          name: "dashboard",
          path: '/dashboard',
          builder: (BuildContext context, GoRouterState state) {
            return DashBoardView();
          },
        ),
        GoRoute(
          name: "draft",
          path: '/content/draft',
          builder: (BuildContext context, GoRouterState state) {
            return DraftView();
          },
        ),
        GoRoute(
          name: 'publish',
          path: '/content/publish',
          builder: (BuildContext context, GoRouterState state) {
            return PublishView();
          },
        ),
        GoRoute(
          name: 'user',
          path: '/user',
          builder: (BuildContext context, GoRouterState state) {
            return UserView();
          },
        ),
        GoRoute(
          name: 'material',
          path: '/material',
          builder: (BuildContext context, GoRouterState state) {
            return MaterialView();
          },
        ),
      ],
    ),
  ],
);
